﻿
''' <summary>Describes the Load-State of a Metis
''' <see cref="Core.Dimensions.MetisDimension">Dimension</see>, 
''' <see cref="Core.Functions.MetisFunction">Function</see> or 
''' <see cref="Core.Flows.MetisFlow">Flow</see></summary>
Public Enum MetisLoadState
    ''' <summary>The entity is newly created and not yet saved to the DB</summary>
    NewDefinition
    ''' <summary>The entity is already exiting in the DB but not comletely loaded (LazyLoaded)</summary>
    NotLoaded
    ''' <summary>The definition is currently fetched from the DB</summary>
    Loading
    ''' <summary>The entity is already exiting in the DB and completely loaded</summary>
    Loaded
End Enum

''' <summary>Exposes the properties/methods that are common to all Metis entities</summary>
Public Interface IMetisCommonEntity
    Inherits System.ComponentModel.INotifyPropertyChanged, IComparable(Of IMetisCommonEntity)

    ''' <summary>The Database-ID (primary key)</summary>
    ReadOnly Property ID() As Integer
    ''' <summary>The name of the field, function, ...</summary>
    Property Name() As String
    ''' <summary>Any additional description</summary>
    Property Annotation() As String

    ''' <summary><see cref="Core.MetisCore.GetNextID">Fetches the next available ID</see> as new ID</summary>
    Function GetNextID() As Integer

End Interface

''' <summary>Exposes the properties/methods that are part of Dimension, Functions and Flow </summary>
Public Interface IMetisEntity
    Inherits IMetisCommonEntity

    ''' <summary>Timestamp when the entity was last loaded</summary>
    ReadOnly Property LastUpdate() As Date
    ''' <summary>Indicating if the entity was changed since loading/last save</summary>
    ReadOnly Property IsModified() As Boolean
    ''' <summary>The Load-State of the entity</summary>
    ReadOnly Property LoadState() As MetisLoadState
    ''' <summary>Timestamp when the corresponding DB-row was added</summary>
    ReadOnly Property CreatedOn() As Date
    ''' <summary>Timestamp when the data of the corresponding DB-row was last changed</summary>
    ReadOnly Property ModifiedOn() As Date

    ''' <summary>Load the entity again from the DB</summary>
    Sub Reload()

    ''' <summary>Save the entity to the DB</summary>
    Sub Save()

    ''' <summary>Raised when a property of the entity is changed</summary>
    Event Changed(ByVal sender As IMetisEntity)
    ''' <summary>Raised after an entity is loaded from the DB</summary>
    Event Loaded(ByVal sender As IMetisEntity)
    ''' <summary>Raised after an entity is saved to the DB</summary>
    Event Saved(ByVal sender As IMetisEntity)

    ''' <summary>Raised while an operation is performed (like saving, loading, function execution)</summary>
    Event Progress(ByVal sender As IMetisEntity, ByVal Progress As MetisProgressEventArgs)

End Interface

''' <summary>Exposes the properties/methods of executable Functions and Flows </summary>
Public Interface IMetisExecutable
    Sub Execute()
End Interface


Public Enum MetisProgressState
    Started
    Processing
    Finished
End Enum

Public Class MetisProgressEventArgs
    Private _ProgressPercentage As Double
    Private _Message As String
    Private _ElapsedTime As Double
    Private _ProgressState As MetisProgressState


End Class


